package com.wind.gtest.adapter;

import java.util.ArrayList;

import com.wind.gtest.R;

import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 省电模式Edit的Adapter
 * 
 * @author df_wind
 * 
 */
public class ListOverlayAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private Resources res;
	private ArrayList<String> overlayout;

	public ListOverlayAdapter(Context context, ArrayList<String> overlayout) {
		inflater = LayoutInflater.from(context);
		res = context.getResources();
		this.overlayout = overlayout;
	}

	// public void setRightBtnListener(ItemRightBtnListener rightBtnListener) {
	// this.rightBtnListener = rightBtnListener;
	// }

	@Override
	public int getCount() {
		// 自定义模式的8项功能
		return overlayout.size();
	}

	@Override
	public String getItem(int position) {
		// 无效
		return overlayout.get(position);
	}

	@Override
	public long getItemId(int position) {
		// 无效
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		// 屏幕亮度与超时
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.item_listview_overlays,
					null);
			holder.img_iconRight = (ImageView) convertView
					.findViewById(R.id.item_list_img_right);
			holder.img_iconLeft = (ImageView) convertView
					.findViewById(R.id.item_list_img_left);
			holder.tv_name = (TextView) convertView
					.findViewById(R.id.item_list_tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		// 内容设置
		if (overlayout.get(position) != null) {
			// holder.img_icon.setImageDrawable(apps.get(position).getIcon());
			holder.tv_name.setText(overlayout.get(position));
			// } else {
			// holder.img_icon.setImageDrawable(res
			// .getDrawable(R.drawable.ic_launcher));

		}
		// holder.tv_name.setText(apps.get(position).getName());
		// // 运行状态设置
		// if (apps.get(position).isRunning()) {
		// holder.tv_isrunning.setText(res
		// .getString(R.string.app_battery_status_running));
		// } else {
		// holder.tv_isrunning.setText(res
		// .getString(R.string.app_battery_status_stopped));
		// }
		// // 进度条设置
		// holder.tv_progress.setText(apps.get(position).getPercent()
		// + res.getString(R.string.saving_view_rate));
		// holder.progressBar.setProgress((int)
		// apps.get(position).getPercent());
		// // 依据程序类型与状态，判断显示图标
		// if (apps.get(position).isSysApp()) {
		// // 系统app
		// holder.img_right.setImageDrawable(res
		// .getDrawable(R.drawable.saving_view_img_sample));
		// } else {
		// // 普通app
		// if (apps.get(position).isRunning()) {
		// holder.img_right.setImageDrawable(res
		// .getDrawable(R.drawable.saving_view_item_add));
		// // 设置监听
		// ImageRightClick rightClick = new ImageRightClick(
		// apps.get(position));
		// holder.img_right.setOnClickListener(rightClick);
		// } else {
		// holder.img_right.setImageDrawable(res
		// .getDrawable(R.drawable.saving_view_img_delete));
		// }
		// }
		return convertView;
	}

	class ViewHolder {
		ImageView img_iconRight;
		ImageView img_iconLeft;
		TextView tv_name;
	}

}
